﻿<Window x:Class="SEToolbox.Views.WindowVoxelMerge"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:commands="clr-namespace:SEToolbox.Services"
        xmlns:support="clr-namespace:SEToolbox.Support"
        xmlns:controls="clr-namespace:SEToolbox.Controls"
        xmlns:converters="clr-namespace:SEToolbox.Converters"
        ResizeMode="CanResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" WindowStyle="ThreeDBorderWindow"
        Title="Asteroid Merge" Height="400" Width="460" MinWidth="260" MinHeight="200" MaxWidth="800" MaxHeight="800" Icon="/SEToolbox;component/app.ico" Style="{StaticResource DefaultWindowStyle}"
        commands:DialogService.IsRegisteredView="True"
        commands:DialogCloser.DialogResult="{Binding CloseResult}"
        FocusManager.FocusedElement="{Binding ElementName=UxStartBox}">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <converters:BusyMouseConverter x:Key="BusyMouseConverter" />
        <converters:EnumToResouceConverter x:Key="EnumToResouceConverter"/>
    </Window.Resources>
    <Window.Cursor>
        <Binding Path="IsBusy" Converter="{StaticResource BusyMouseConverter}"/>
    </Window.Cursor>
    <Grid>
        <Grid Margin="8">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Grid.Column="0" Margin="0,0,0,4">
                <Grid HorizontalAlignment="Left" Width="320" Margin="1,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="4"/>
                        <RowDefinition/>
                        <RowDefinition Height="4"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Text="Action:" VerticalAlignment="Center" Margin="0,0,4,0"/>
                    <ComboBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Width="200" ItemsSource="{Binding Source={StaticResource VoxelMergeTypeEnum}}" SelectedValue="{Binding VoxelMergeType}" Name="UxStartBox">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=., Converter={StaticResource EnumToResouceConverter}}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <TextBlock Grid.Row="2" Grid.Column="0" Text="New Filename:" VerticalAlignment="Center" Margin="0,0,4,0"/>
                    <TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Width="200" Text="{Binding MergeFileName}"/>
                    <CheckBox Grid.Row="4" Grid.Column="1" Content="Remove original asteroids" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding RemoveOriginalAsteroids}" />
                </Grid>
            </Grid>
            <Grid Grid.Row="1">
                <Grid.Resources>
                    <Color x:Key="ColorLeft">#FFFFD700</Color>
                    <Color x:Key="ColorLeft2">#80404000</Color>
                    <Color x:Key="ColorRight">#FF8B0000</Color>
                    <Color x:Key="ColorRight2">#80400000</Color>
                    <SolidColorBrush x:Key="Border" Color="#FFA9A9A9" />
                    <SolidColorBrush x:Key="BorderDash" Color="#80A9A9A9" />
                    <SolidColorBrush x:Key="FillLeft" Color="{StaticResource ColorLeft}" />
                    <SolidColorBrush x:Key="FillRight" Color="{StaticResource ColorRight}" />
                    <RadialGradientBrush x:Key="EdgeLeft">
                        <RadialGradientBrush.GradientStops>
                            <GradientStop Color="{StaticResource ColorLeft}" Offset="0.9" />
                            <GradientStop Color="{StaticResource ColorLeft2}" Offset="1" />
                        </RadialGradientBrush.GradientStops>
                    </RadialGradientBrush>
                    <RadialGradientBrush x:Key="EdgeRight">
                        <RadialGradientBrush.GradientStops>
                            <GradientStop Color="{StaticResource ColorRight}" Offset="0.9" />
                            <GradientStop Color="{StaticResource ColorRight2}" Offset="1" />
                        </RadialGradientBrush.GradientStops>
                    </RadialGradientBrush>
                    <SolidColorBrush x:Key="BackColor" Color="#FF000000" />
                </Grid.Resources>
                <Grid.Style>
                    <Style>
                        <Setter Property="Canvas.Visibility" Value="Hidden"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsValidMerge}" Value="True">
                                <Setter Property="Canvas.Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>

                <!--union volume left to right-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.UnionVolumeLeftToRight}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="10 0 0 0" Fill="{StaticResource EdgeLeft}"/>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="150 0 0 0" Fill="{StaticResource EdgeRight}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillLeft}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillRight}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,51 A 98,98 40 0 1 200,189" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,51 A 98,98 40 1 0 200,189" />
                    <Ellipse Stroke="{StaticResource Border}" StrokeThickness="4" Margin="170 20 0 0" Width="200" Height="200"/>
                </Canvas>

                <!--union volume right to left-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.UnionVolumeRightToLeft}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="150 0 0 0" Fill="{StaticResource EdgeRight}"/>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="10 0 0 0" Fill="{StaticResource EdgeLeft}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillRight}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillLeft}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,189 A 98,98 40 0 1 200,51" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,189 A 98,98 40 1 0 200,51" />
                    <Ellipse Stroke="{StaticResource Border}" StrokeThickness="4" Margin="30 20 0 0" Width="200" Height="200" />
                </Canvas>

                <!--union material right to left-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.UnionMaterialRightToLeft}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="10 0 0 0" Fill="{StaticResource EdgeLeft}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource BackColor}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillLeft}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Path StrokeThickness="0" Fill="{StaticResource FillRight}" Data="M 200,49 A 98,98 40 0 1 200,189 M 200,189 A 98,98 40 0 1 200,49" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,189 A 98,98 40 1 0 200,51" />
                    <Ellipse Stroke="{StaticResource Border}" StrokeThickness="4" Margin="30 20 0 0" Width="200" Height="200" />
                </Canvas>

                <!--union material left to right-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.UnionMaterialLeftToRight}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="150 0 0 0" Fill="{StaticResource EdgeRight}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource BackColor}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillRight}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Path StrokeThickness="0" Fill="{StaticResource FillLeft}" Data="M 200,49 A 98,98 40 0 1 200,189 M 200,189 A 98,98 40 0 1 200,49" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeDashArray="4 0 2" StrokeThickness="4" Data="M 200,51 A 98,98 40 1 0 200,189" />
                    <Ellipse Stroke="{StaticResource Border}" StrokeThickness="4" Margin="170 20 0 0" Width="200" Height="200"/>
                </Canvas>

                <!--subtract volume right from left-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.SubtractVolumeRightFromLeft}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="10 0 0 0" Fill="{StaticResource EdgeLeft}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillLeft}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource BackColor}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,51 A 98,98 40 1 0 200,189" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,189 A 98,98 40 1 0 200,51" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,189 A 98,98 40 0 1 200,51" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,51 A 98,98 40 0 1 200,189" />
                </Canvas>

                <!--subtract volume left from right-->
                <Canvas Background="{StaticResource BackColor}" Width="400" Height="240">
                    <Canvas.Style>
                        <Style>
                            <Setter Property="Canvas.Visibility" Value="Hidden"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VoxelMergeType}" Value="{x:Static support:VoxelMergeType.SubtractVolumeLeftFromRight}">
                                    <Setter Property="Canvas.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Canvas.Style>
                    <Ellipse Width="240" Height="240" StrokeThickness="0" Margin="150 0 0 0" Fill="{StaticResource EdgeRight}"/>
                    <Ellipse Width="200" Height="200" Fill="{StaticResource FillRight}" StrokeThickness="0" Margin="170 20 0 0" />
                    <Ellipse Width="200" Height="200" Fill="{StaticResource BackColor}" StrokeThickness="0" Margin="30 20 0 0" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,189 A 98,98 40 1 0 200,51" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeDashArray="4 0 2" StrokeThickness="4" Data="M 200,51 A 98,98 40 1 0 200,189" />
                    <Path Stroke="{StaticResource Border}" StrokeThickness="4" Data="M 200,51 A 98,98 40 0 1 200,189" />
                    <Path Stroke="{StaticResource BorderDash}" StrokeThickness="4" StrokeDashArray="4 0 2" Data="M 200,189 A 98,98 40 0 1 200,51" />
                </Canvas>

                <TextBlock Text="{Binding SelectionLeft.Name}" Margin="-150,0,0,0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock.Effect>
                        <DropShadowEffect Color="Black" BlurRadius="3" ShadowDepth="0" />
                    </TextBlock.Effect>
                </TextBlock>
                <TextBlock Text="{Binding SelectionRight.Name}" Margin="150,0,0,0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock.Effect>
                        <DropShadowEffect Color="Black" BlurRadius="3" ShadowDepth="0" />
                    </TextBlock.Effect>
                </TextBlock>
            </Grid>

            <Grid Grid.Row="1">
                <Grid.Style>
                    <Style>
                        <Setter Property="Canvas.Visibility" Value="Collapsed"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsValidMerge}" Value="False">
                                <Setter Property="Canvas.Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <TextBlock Text="The selected Asteroids do not overlap." HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Grid>
            <Grid Grid.Row="2" Margin="0,8,0,0">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                    <Button Width="90" Command="{Binding ApplyCommand}" Content="Apply" IsDefault="True" Margin="0,0,8,0" />
                    <Button Width="90" Command="{Binding CancelCommand}" Content="Cancel" IsCancel="True"/>
                </StackPanel>
            </Grid>
        </Grid>
        <controls:BusyIndicator Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" />
    </Grid>
</Window>
